#include "./tim_list.h"
#ifndef TIM_CIRCLELIST_H
#define TIM_CIRCLELIST_H

namespace tim
{
	template<typename T>
	class circlelist: public tim::list<T>
	{
		protected:
			node<T>* cur;//现态指针
			void init()
			{
				T _temp;
				this->header = new node<T>(_temp);
				this->trailer = new node<T>(_temp);

				this->header->insert_succ(this->trailer);
				this->header->insert_pred(this->trailer);
				this->trailer->insert_pred(this->header);
				this->trailer->insert_succ(this->header);
				this->_size = 0;
			}

		public:
			circlelist() { init();};
			circlelist(T* begin, T* end): list<T>(begin, end) {};
			void cur_init() { cur = this->first();} //初始化现态指针
			void cur_init2() { cur = this->last();}
			T& next()
			{
				T& _data = cur->data;
				cur = cur->succ;
				if(cur == this->trailer) cur = this->first();
				return _data;
			}
	};
}


#endif
